
{extend name='bus@public/wrap'}

{block name="main"}

<main role="main">
    <div class="container-fluid">
        <form class="mt-5">


            <div class="form-inline form-group form-row">
                <div class="form-group col-sm-6 form-row">
                    <label class="col-sm-3">父菜单</label>
                    <div class="col-sm-9">
                        <select class="form-control" name="pid" data-value="{$data.pid}">
                            <option></option>
                            {foreach $plist as $key=>$vo }
                            <option value="{$vo.id}">{$vo.title}</option>
                            {/foreach}
                        </select>
                    </div>
                </div>

                <div class="form-group col-sm-6 form-row">
                    <label class="col-sm-3">状  态</label>
                    <div class="col-sm-9">
                        <select name="status" class="form-control" placeholder="请选择状态"
                                data-value="{$data.status}">
                            <option value="正常" selected>正常</option>
                            <option value="禁用">禁用</option>
                        </select>
                    </div>
                </div>
            </div>

            <div class="form-inline form-group form-row">
                <div class="form-group col-sm-6 form-row">
                    <label class="col-sm-3">名  称</label>
                    <div class="col-sm-9">
                        <input type="text" class="form-control" name="title" value="{$data.title}"  placeholder="请输入名称" >
                    </div>
                </div>
                <div class="form-group col-sm-6 form-row">
                    <label class="col-sm-3">动作</label>
                    <div class="col-sm-9">
                        <input type="text" class="form-control" name="url" value="{$data.url}"  placeholder="请输入动作" >
                    </div>
                </div>

            </div>

            <div class="form-inline form-group form-row">
                <div class="form-group col-sm-6 form-row">
                    <label class="col-sm-3">排序</label>
                    <div class="col-sm-9">
                        <input type="text" class="form-control" name="sort" value="{$data.sort}"  placeholder="请输入备注" >
                    </div>
                </div>
                <div class="form-group col-sm-6 form-row">
                    <label class="col-sm-3">图标</label>
                    <div class="col-sm-9">
                        <input type="text" class="form-control" name="ico" value="{$data.ico}"  placeholder="请输入图标" >
                        <a target="_blank" href="http://fontawesome.dashgame.com/">选择图标</a>
                    </div>
                </div>
            </div>


            <div class="mt-5 mb-5 bd-example text-center">
                <input type='hidden' value='{$Think.get.id}' name='id'/>
                <input class="btn btn-secondary mr-2" type="button" value=" 保 存 " id="submit">
                <input class="btn btn-secondary ml-2" type="button" value=" 取 消 " id="close">
            </div>

        </form>
    </div>
</main>


<script>
    
    $(function () {

        //取消
        $("#close").on("click",function () {
            var index = parent.layer.confirm('你确定要取消编辑吗？', {
                btn: ['确定','取消']
            }, function(){
                parent.layer.close(index);
                frame.closeFrame();
            });
        });

        //提交数据
        $("#submit").on("click",function () {
            var data = $("form").serializeObject();
            frame.ajax({
                url:"/admin/develop/menu_edit",
                type:"post",
                data:data,
            }).then(function (data) {
                if(data.code == 0){
                    frame.closeFrame();
                    parent.frame.show(data);
                    parent.bind();
                } else {
                    parent.frame.show(data);
                }
            });
        });
        
    });

</script>
{/block}